<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.tjsinfo.tjsoa.system.vo.User"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>粮油集团办公自动化协作平台</title>
    <meta http-equiv="x-ua-compatible" content="ie=7" />
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link href="<%=basePath%>style/txlk7.css" rel="stylesheet" type="text/css" id="txlk7"/>
	<link href="<%=basePath%>style/txlz7.css" rel="stylesheet" type="text/css" id="txlz7"/>
	<style type="text/css">
			td {
				font:12px/170% "宋体", "新宋体", "黑体"; color:#000
			}
			th {
				font:12px/170% "宋体", "新宋体", "黑体"; color:#000
			}
	</style>
	<style>
		 #divgroup {width:100%;height:100%;overflow:hidden;}
         .trBgColor { background-color:#A4D7E8; cursor: hand;}
         .trGroupColor { background-color:#C3EBF9; cursor: hand;}
         .trHiddivColor { background-color:#c3ebf9; cursor: hand;}
         
		.senddown {
			height: 27.1%;
			width: 98%;
			margin-top:0px;
			border:1px #9DB0BC solid;
			background:#fff;
			float:left;
			margin-left:3px;
		}
		.senddown1 {
			height: 77.4%;
			width: 98%;
			margin-top:6px;
			border:1px #9DB0BC solid;
			background:#fff;
			float:left;
			margin-left:3px;
		}
		.jkdaaabbb{
border-left:1px #d0d0d0 solid; border-bottom:1px #d0d0d0 solid;margin:0px;
}
.jkdaaabbb td{
border-top:1px #d0d0d0 solid; border-right:1px #d0d0d0 solid; padding-top:2px;padding-bottom:2px;color: #232323; text-align:center
}
   </style>
                
	<script type='text/javascript' src='<%=basePath%>dwr/interface/FileDocumentGroupBo.js'></script>
	<script type='text/javascript' src='<%=basePath%>dwr/interface/FileDocumentUserBo.js'></script>
	<script type='text/javascript' src="<%=basePath%>dwr/engine.js"></script>
	<script type='text/javascript' src="<%=basePath%>dwr/util.js"></script>
	<%
		User user = (User)session.getAttribute("user");
		String first = (String)request.getAttribute("first");
		if(first == null)first="";
	 %>
    <script type='text/javascript' src='<%=basePath%>js/pack.js'></script>
	<script type="text/javascript">
		window.onload = function(){windowonload();}
		var copyid = '';
		var copygroup = '';
		var first = '<%=first %>';
		var group_id = '';
		function windowonload(){
			if(first != 'shi'){
				document.getElementById('td1').style.display="block";
				clock();
			}else{
				document.getElementById("xiaoguo").style.display = "none";
				document.getElementById('td1').style.backgroundColor = "";
			}
			FileDocumentGroupBo.getAllGroup(Group);
			
		}
		var i = 10;
		function clock(){
			i=i-1
			if(i>0){
				setTimeout("clock();",500);
			}else{
				document.getElementById('xiaoguo').style.display="none";
				document.getElementById('td1').style.backgroundColor = "";
			}
		}
		
		var groupNum = 0;
		var fu = null;
		function Group(fuzhi){
			var divgroup = document.getElementById("divgroup");
			fu = fuzhi;
			groupNum = fu.length/2;
			var liebiaoGroup = '<table id="grouptable" border="0" width="100%" cellspacing="0" cellpadding="0">';
			var i = 0;
			for(var a=0;a<fu.length;a=a+2){
				if(fu[a+1].length>=9){
					liebiaoGroup += '<tr id="group'+i+'" onmouseover=\'this.className=\"trGroupColor\"\' onmouseout=\'this.className=\"\"\' onmouseup=\"ClickGroup('+i+');\"><td width="23px" height="24px" align="center"><input type="checkbox" id="checkgroup" value="'+fu[a]+'" onpropertychange="mugroup()"/></td><td height="24px" valign="middle"><a id=\"groupA'+i+'\" title=\"'+fu[a+1]+'\" onclick="getDownUser(\''+fu[a]+'\')" >'+fu[a+1].substring(0,8)+'</a></td></tr>';
				}else{
					liebiaoGroup += '<tr id="group'+i+'" onmouseover=\'this.className=\"trGroupColor\"\' onmouseout=\'this.className=\"\"\' onmouseup=\"ClickGroup('+i+');\"><td width="23px" height="24px" align="center"><input type="checkbox" id="checkgroup" value="'+fu[a]+'" onpropertychange="mugroup()"/></td><td height="24px" valign="middle"><a id=\"groupA'+i+'\" onclick="getDownUser(\''+fu[a]+'\')" >'+fu[a+1]+'</a></td></tr>';
				}
				i++;
			}
			if(fu.length>30){
				if(fu.length>38){
					document.getElementById("zushang").style.display = "block";
					document.getElementById("zuxia").style.display = "block";
				}else{
					document.getElementById("zushang").style.display = "none";
					document.getElementById("zuxia").style.display = "none";
				}
			}else{
				document.getElementById("zushang").style.display = "none";
				document.getElementById("zuxia").style.display = "none";
			}
			liebiaoGroup += '</table>';
			divgroup.innerHTML= liebiaoGroup;
		}
        
        var groupA = -1;
        function ClickGroup(i){
        	
			if(groupA!=-1)
			document.getElementById("group"+groupA).onmouseout = function(){this.className=''};
        	for(var a = 0 ; a<groupNum;a++ ){
				var b = document.getElementById("group"+a);
				var c = document.getElementById("groupA"+a);
				if(a == i){
					b.className="trGroupColor";
					c.style.fontWeight="bold";
					b.onmouseout = null;
					groupA = a;
				}else{
					c.style.fontWeight="100";
					b.className='';
				}
			}
        }
        
		function getDownUser(groupid){
			
			var obj=document.getElementsByName("checkgroup");
		  	for(var   i=0;i<obj.length;i++){   
			  	if(obj[i].checked==true){
			  		if(confirm('您是否保存对已选种类下载用户的设置？')){
			  			submitform();
			  		} 
			  	}
		  	}  
		  	
			var yidong = document.getElementById('yidong');
			yidong.style.display = 'none';
			var downUserDiv = document.getElementById('shoudiv');
			var inner = '<table class="jkdaaabbb" width="187px"><tr><td width="93px">部门</td><td width="94px">姓名</td></tr>';
			FileDocumentUserBo.getDownUser(groupid,{
				callback:function(str){
					if(str!=null){
						for(var i=0;i<str.length;i+=2){
							inner += '<tr><td>'+str[i]+'</td><td>'+str[i+1]+'</td></tr>';
						}
					}
					downUserDiv.innerHTML = inner+'</table>';
				}
			});
			var objs =document.getElementsByTagName("input");
			  for(var i=0; i<objs.length; i++) {
			    if(objs[i].type.toLowerCase() == "checkbox" )
			      objs[i].checked = false;
			  }
		}
		
		function mugroup(){
		
		  	var obj=document.getElementsByName("checkgroup");
		  	var yidong = document.getElementById('yidong');
		  	var bl = true;  
		  	for(var   i=0;i<obj.length;i++){   
			  	if(obj[i].checked==true){   
					yidong.style.display = 'block';
					bl = false;   
			  	}
		  	}  
		  	if(bl){
		  		yidong.style.display = 'none';
		  	}
		  	var downUserDiv = document.getElementById('shoudiv');
		  	downUserDiv.innerHTML = '<ul id="list2"></ul>';
		}
	</script>
	<%-- 向上向下滑动--%>
	 <script type="text/JavaScript">
var sh;
preLeft=0; currentLeft=0; stopscroll=false; getlimit=0;preTop=0; currentTop=0;
function scrollLeft()
{
	var marquees = document.getElementById("divgroup");
	if(stopscroll==true) return;
	preLeft=marquees.scrollTop;
	marquees.scrollTop+=2;
	if(preLeft==marquees.scrollTop)
	{
		//marquees.scrollLeft=templayer.offsetWidth-marqueesWidth+1;
	}
}

function scrollRight()
{
	var marquees = document.getElementById("divgroup");
	if(stopscroll==true) return;

	preLeft=marquees.scrollTop;
	marquees.scrollTop-=2;
	if(preLeft==marquees.scrollTop)
	{
		if(!getlimit)
		{
			marquees.scrollLeft=templayer.offsetWidth*2;
			getlimit=marquees.scrollLeft;
		}
		marquees.scrollLeft-=1;
	}
}

function Left()
{
	stopscroll = false;
	sh = setInterval("scrollLeft()",30);
}

function Right()
{
	stopscroll = false;
	sh = setInterval("scrollRight()",30);
}

function StopScroll()
{
	stopscroll = true;
	clearInterval( sh );
}
</script>
<script type="text/javascript">
	function move2()
{
	var checkbox2 = document.getElementsByName('checkbox2');
	var list2 = document.getElementById('list2');
	var length  = checkbox2.length;
	for(var a = 0; a<checkbox2.length; a++)
	{
			var check1 = checkbox2[a];
			if(check1.checked == true)
			{
				var li = document.getElementById(check1.value);
				list2.removeChild(li);
				a--;
			}		
	}
}
</script>

    <script type="text/javascript">



//返回选中的记录（叶节点）
var user_id = '<%=user.getUser_id() %>';
function test3(){
				 var checkbox2 = document.getElementsByName('checkbox2');
				 var list2 = document.getElementById('list2');
 				 var a =treeFenju2.getNodesMoji();
  				if(a.length>0) {
  				var temp=a.toString();
  				var user=temp.split(',');
  				var names=",";
  				var ids=",";
  				
	  		for(var a=0;a<user.length;a++){
	  			var str=user[a];
	  			var s=str.split('.');
	  			ids=ids+s[0]+",";  	 	
	  			names=names+s[1]+",";
	  			if(checkbox2.length > 0)
	  			{
	  			
	  				var length = checkbox2.length;
	  				for(var i =0;i<length; i++)
	  				{
	  					var c = i + 1;
	  					if(checkbox2[i].getAttribute('value') == s[0])
	  					{
	  				
	  						break;
	  					}
	  					else if(c==length)
	  					{
	  						var li = document.createElement('li');
	  						list2.appendChild(li);
	  						li.outerHTML="<li id='"+s[0]+"'><input type='checkbox' name='checkbox2' value='"+s[0]+"' />"+s[1]+"</li>";		
	  					}
	  					// else if(s[0] == user_id)
	  					// {
	  					   // break;
	  					// }
	  					
	  				}	
	  			}
	  			else 
	  			{	
	  					var li = document.createElement('li');
	  					list2.appendChild(li);
	  					li.outerHTML="<li id='"+s[0]+"'><input type='checkbox' name='checkbox2' value='"+s[0]+"' />"+s[1]+"</li>";
	  			}	
	  			}
	
  	}else{
		document.getElementById('tree').style.display='none';
		document.getElementById('ceshi5').style.display='none';
		
		}
	}
	</script>
  </head>
  
  <body>
  <div id="right" style="z-index: 19">
  <div style="height: 97%">
      <div class="p_01" style="height:29px; border-left:1px #175A7F solid; border-right:1px #175A7F solid; background:url(<%=basePath%>images/m_icon14.gif) repeat-x; padding-left:10px; position:relative;">
      <table width="100%">
      <tr>
     	 <td width="19%">
		    <ul>
               <li class="s09" style="background:url(<%=basePath%>images/qdz.gif) no-repeat 0 7px;"><a href="javaScript:submitform()">确定</a></li>
               <li class="s10" style="background:url(<%=basePath%>images/qxz.gif) no-repeat 0 7px;"><a href="<%=basePath%>tjsinfo/tjsoa/fileDocument/loginFileDocument.do">返回</a></li>
            </ul>
            </td>
            <td width="11%" align="center" style="background-color: #F49243;display: none" id="td1">
            <div id="xiaoguo" style="width: 100%;" align="center"><img src="<%=basePath%>images/gif-0443.gif" />	<b style="color: white;">已成功设置</b></div>
            </td>
            <td width="20%" align="right"><img src="<%=basePath%>images/zucopyicon.gif"/><a style="color: white">		<b>设置下载用户&nbsp;&nbsp;&nbsp;</b></a></td>
            </tr>
            </table>
	  </div>
	 <form action="<%=basePath %>tjsinfo/tjsoa/fileDocument/downUser.do" name="form1" method="post">
	  <input name="groupids" id="groupids" style="display: none"/>
	  <input name="users" id="users" style="display: none"/>
      <table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%" style="border-right:#CCCCCC solid 1px;">
          <tr>
            <td width="15%" valign="top" align="left" height="100%">
              <div class="conren" style="height: 93%">
                <div class="h"><table width="101%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="20%" align="center"><img src="<%=basePath%>images/zuicon.png"/></td>
                        <td align="left">文档种类<br/></td>
                      </tr>
                    </table>
                </div>
                <div id="zushang" class="zuxia" onmouseout=StopScroll() onmouseover=Right() style='cursor:pointer;display: none;'></div>
                  <table width="102%" height="90%" border="0" cellspacing="0" cellpadding="0" id="grouptable">
                    <tr height="100%" valign="top">
                      <td>
                      	<div id="divgroup">
                      	</div>
                      	<DIV id=templayer style="LEFT: 0px; VISIBILITY: hidden; POSITION: absolute; TOP: 0px"></DIV>
                      </td>
                    </tr>
                </table>
                <div id="zuxia" class="zushang" onmouseout=StopScroll() onmouseover=Left() style='cursor:pointer;display: none;'></div>
              </div>
            </td>
            <td width="100%" valign="top" height="100%">
               <div id="divindex" class="contab" style="height: 93%;width: 100%">
               	<table width="100%" border="0" cellspacing="0" cellpadding="0" height="80%">
      			<tr height="5%"></tr>
               	<tr>
               		<td width="5%"></td>
               		<td width="50%" valign="middle" align="left" height="100%">
               			<div style="height: 98%;width:95%;overflow: scroll;">
                                	<div id="tree"></div>
               						<div id="ceshi5">df</div>                        
                       </div> 
               		</td>
               		<td valign="middle" height="90%" width="13%">
               			<div id="yidong">
               			<a href="javaScript:test3();"><img src="<%=basePath%>images/tongbu_07.gif" /></a><br/><br/><br/>
               			<a href="javaScript:move2();"><img src="images/tongbu_08.gif"/></a>
               			</div>
               		</td>
               		<td valign="middle" height="100%">
               			 <table width="197" border="0" cellpadding="0" cellspacing="0" height="100%">
                                  <tr>
                                    <td background="<%=basePath%>images/yxfs.gif" height="30" colspan="2">&nbsp;</td>
                                  </tr>
                                  <tr>
                                    <td background="<%=basePath%>images/tongbu05.gif" height="97%" valign="top">
                                    <table>
                                    	<tr>
                                    		<td>
                                    <div id="shoudiv" style="overflow-y:scroll; overflow-x:hidden;width:187px;height:410px; line-height:22px; text-align:left; ">
                                     <ul id="list2"></ul>
                                    </div>
                                    		</td>
                                    		<td>&nbsp;</td>
                                    	</tr>
                                    </table>
                                                            </td>
                                  </tr>
                                  <tr>
                                    <td background="<%=basePath%>images/tongbu06.gif" height="8" colspan="2"></td>
                                  </tr>
                               </table>        
               		</td>
               	</tr>
               </table>
              </div>
            </td>
          </tr>
      </table>
      </form>
      </div>
</div>
<script type="text/javascript">
	function submitform(){
			var sendgroup = '';
			var obj=document.getElementsByName("checkgroup");
		  	for(var   i=0;i<obj.length;i++){   
			  	if(obj[i].checked==true){   
					var check1 = obj[i].value;
					sendgroup += check1+",";  
			  	}
		  	}
		  	if(sendgroup==''){
		  		if(confirm('您未选择设置的文档种类，是否继续进行设置？')){
			  		return;
			  	}else{
			  		location.href = '<%=basePath%>tjsinfo/tjsoa/fileDocument/loginFileDocument.do';
			  		return;
			  	}
		  	}
			
			document.getElementById('groupids').value = sendgroup;
			
			var checkbox2 = document.getElementsByName('checkbox2');
			var length1  = checkbox2.length;
			var sendusers = '';
			for(var a = 0; a<length1; a++)
			{
				var check1 = checkbox2[a].value;
				sendusers += check1+",";	
			}
			
			document.getElementById('users').value = sendusers;
			document.form1.submit();
		}
</script>
  </body>
</html>
